Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for bug with setting object/array in state in useEffect hook. Fix #1306 #1307

Merged
merged 2 commits into from
Sep 25, 2023

Conversation

mokkabonna
Copy link
Contributor

Simple test case to show fail for bug described in #1306

Not sure how to fix it though.

Test output:

 FAIL  packages/core/core.test.mts > createPrompt() > useEffect: works with setting state at once with objects
RangeError: Maximum call stack size exceeded
 ❯ new AsyncResource node:async_hooks:160:14
 ❯ Function.bind node:async_hooks:261:13
 ❯ Module.withUpdates packages/core/src/lib/hook-engine.mts:76:24
     74|   };
     75|
     76|   return AsyncResource.bind(wrapped);
       |                        ^
     77| }
     78|
 ❯ packages/core/src/lib/use-keypress.mts:14:21
 ❯ packages/core/src/lib/hook-engine.mts:111:23
 ❯ packages/core/src/lib/hook-engine.mts:122:9
 ❯ packages/core/src/lib/hook-engine.mts:121:25
 ❯ wrapped packages/core/src/lib/hook-engine.mts:66:25
 ❯ AsyncResource.runInAsyncScope node:async_hooks:203:9

@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
packages/core/src/lib/hook-engine.mts 81.39% <100.00%> (+0.29%) ⬆️

... and 3 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@SBoudrias SBoudrias changed the title Add unit test for bug with setting object/array in state in useEffect hook Add unit test for bug with setting object/array in state in useEffect hook. Fix #1306 Sep 25, 2023
@SBoudrias SBoudrias merged commit 5036180 into SBoudrias:master Sep 25, 2023
@SBoudrias
Copy link
Owner

Thanks for the test!! It helped a lot 😄

Got a bit thrown away by that AsyncResource error. But it was a simple infinite loop bug 🤦🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants